\(\int (a+b \tan ^2(c+d x)) \, dx\) [253]

   Optimal result
   Rubi [A] (verified)
   Mathematica [A] (verified)
   Maple [A] (verified)
   Fricas [A] (verification not implemented)
   Sympy [A] (verification not implemented)
   Maxima [A] (verification not implemented)
   Giac [B] (verification not implemented)
   Mupad [B] (verification not implemented)

Optimal result

Integrand size = 12, antiderivative size = 19 \[ \int \left (a+b \tan ^2(c+d x)\right ) \, dx=a x-b x+\frac {b \tan (c+d x)}{d} \]

[Out]

a*x-b*x+b*tan(d*x+c)/d

Rubi [A] (verified)

Time = 0.02 (sec) , antiderivative size = 19, normalized size of antiderivative = 1.00, number of steps used = 3, number of rules used = 2, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.167, Rules used = {3554, 8} \[ \int \left (a+b \tan ^2(c+d x)\right ) \, dx=a x+\frac {b \tan (c+d x)}{d}-b x \]

[In]

Int[a + b*Tan[c + d*x]^2,x]

[Out]

a*x - b*x + (b*Tan[c + d*x])/d

Rule 8

Int[a_, x_Symbol] :> Simp[a*x, x] /; FreeQ[a, x]

Rule 3554

Int[((b_.)*tan[(c_.) + (d_.)*(x_)])^(n_), x_Symbol] :> Simp[b*((b*Tan[c + d*x])^(n - 1)/(d*(n - 1))), x] - Dis
t[b^2, Int[(b*Tan[c + d*x])^(n - 2), x], x] /; FreeQ[{b, c, d}, x] && GtQ[n, 1]

Rubi steps \begin{align*} \text {integral}& = a x+b \int \tan ^2(c+d x) \, dx \\ & = a x+\frac {b \tan (c+d x)}{d}-b \int 1 \, dx \\ & = a x-b x+\frac {b \tan (c+d x)}{d} \\ \end{align*}

Mathematica [A] (verified)

Time = 0.01 (sec) , antiderivative size = 28, normalized size of antiderivative = 1.47 \[ \int \left (a+b \tan ^2(c+d x)\right ) \, dx=a x-\frac {b \arctan (\tan (c+d x))}{d}+\frac {b \tan (c+d x)}{d} \]

[In]

Integrate[a + b*Tan[c + d*x]^2,x]

[Out]

a*x - (b*ArcTan[Tan[c + d*x]])/d + (b*Tan[c + d*x])/d

Maple [A] (verified)

Time = 0.03 (sec) , antiderivative size = 20, normalized size of antiderivative = 1.05

method result size
norman \(\left (a -b \right ) x +\frac {b \tan \left (d x +c \right )}{d}\) \(20\)
parallelrisch \(-\frac {b \left (d x -\tan \left (d x +c \right )\right )}{d}+a x\) \(23\)
default \(a x +\frac {b \left (\tan \left (d x +c \right )-\arctan \left (\tan \left (d x +c \right )\right )\right )}{d}\) \(26\)
parts \(a x +\frac {b \left (\tan \left (d x +c \right )-\arctan \left (\tan \left (d x +c \right )\right )\right )}{d}\) \(26\)
derivativedivides \(\frac {b \tan \left (d x +c \right )+\left (a -b \right ) \arctan \left (\tan \left (d x +c \right )\right )}{d}\) \(27\)
risch \(a x -b x +\frac {2 i b}{d \left ({\mathrm e}^{2 i \left (d x +c \right )}+1\right )}\) \(29\)

[In]

int(a+b*tan(d*x+c)^2,x,method=_RETURNVERBOSE)

[Out]

(a-b)*x+b*tan(d*x+c)/d

Fricas [A] (verification not implemented)

none

Time = 0.26 (sec) , antiderivative size = 21, normalized size of antiderivative = 1.11 \[ \int \left (a+b \tan ^2(c+d x)\right ) \, dx=\frac {{\left (a - b\right )} d x + b \tan \left (d x + c\right )}{d} \]

[In]

integrate(a+b*tan(d*x+c)^2,x, algorithm="fricas")

[Out]

((a - b)*d*x + b*tan(d*x + c))/d

Sympy [A] (verification not implemented)

Time = 0.08 (sec) , antiderivative size = 20, normalized size of antiderivative = 1.05 \[ \int \left (a+b \tan ^2(c+d x)\right ) \, dx=a x + b \left (\begin {cases} - x + \frac {\tan {\left (c + d x \right )}}{d} & \text {for}\: d \neq 0 \\x \tan ^{2}{\left (c \right )} & \text {otherwise} \end {cases}\right ) \]

[In]

integrate(a+b*tan(d*x+c)**2,x)

[Out]

a*x + b*Piecewise((-x + tan(c + d*x)/d, Ne(d, 0)), (x*tan(c)**2, True))

Maxima [A] (verification not implemented)

none

Time = 0.37 (sec) , antiderivative size = 23, normalized size of antiderivative = 1.21 \[ \int \left (a+b \tan ^2(c+d x)\right ) \, dx=a x - \frac {{\left (d x + c - \tan \left (d x + c\right )\right )} b}{d} \]

[In]

integrate(a+b*tan(d*x+c)^2,x, algorithm="maxima")

[Out]

a*x - (d*x + c - tan(d*x + c))*b/d

Giac [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 231 vs. \(2 (19) = 38\).

Time = 0.36 (sec) , antiderivative size = 231, normalized size of antiderivative = 12.16 \[ \int \left (a+b \tan ^2(c+d x)\right ) \, dx=a x + \frac {{\left (\pi - 4 \, d x \tan \left (d x\right ) \tan \left (c\right ) - \pi \mathrm {sgn}\left (2 \, \tan \left (d x\right )^{2} \tan \left (c\right ) + 2 \, \tan \left (d x\right ) \tan \left (c\right )^{2} - 2 \, \tan \left (d x\right ) - 2 \, \tan \left (c\right )\right ) \tan \left (d x\right ) \tan \left (c\right ) - \pi \tan \left (d x\right ) \tan \left (c\right ) + 2 \, \arctan \left (\frac {\tan \left (d x\right ) \tan \left (c\right ) - 1}{\tan \left (d x\right ) + \tan \left (c\right )}\right ) \tan \left (d x\right ) \tan \left (c\right ) + 2 \, \arctan \left (\frac {\tan \left (d x\right ) + \tan \left (c\right )}{\tan \left (d x\right ) \tan \left (c\right ) - 1}\right ) \tan \left (d x\right ) \tan \left (c\right ) + 4 \, d x + \pi \mathrm {sgn}\left (2 \, \tan \left (d x\right )^{2} \tan \left (c\right ) + 2 \, \tan \left (d x\right ) \tan \left (c\right )^{2} - 2 \, \tan \left (d x\right ) - 2 \, \tan \left (c\right )\right ) - 2 \, \arctan \left (\frac {\tan \left (d x\right ) \tan \left (c\right ) - 1}{\tan \left (d x\right ) + \tan \left (c\right )}\right ) - 2 \, \arctan \left (\frac {\tan \left (d x\right ) + \tan \left (c\right )}{\tan \left (d x\right ) \tan \left (c\right ) - 1}\right ) - 4 \, \tan \left (d x\right ) - 4 \, \tan \left (c\right )\right )} b}{4 \, {\left (d \tan \left (d x\right ) \tan \left (c\right ) - d\right )}} \]

[In]

integrate(a+b*tan(d*x+c)^2,x, algorithm="giac")

[Out]

a*x + 1/4*(pi - 4*d*x*tan(d*x)*tan(c) - pi*sgn(2*tan(d*x)^2*tan(c) + 2*tan(d*x)*tan(c)^2 - 2*tan(d*x) - 2*tan(
c))*tan(d*x)*tan(c) - pi*tan(d*x)*tan(c) + 2*arctan((tan(d*x)*tan(c) - 1)/(tan(d*x) + tan(c)))*tan(d*x)*tan(c)
 + 2*arctan((tan(d*x) + tan(c))/(tan(d*x)*tan(c) - 1))*tan(d*x)*tan(c) + 4*d*x + pi*sgn(2*tan(d*x)^2*tan(c) +
2*tan(d*x)*tan(c)^2 - 2*tan(d*x) - 2*tan(c)) - 2*arctan((tan(d*x)*tan(c) - 1)/(tan(d*x) + tan(c))) - 2*arctan(
(tan(d*x) + tan(c))/(tan(d*x)*tan(c) - 1)) - 4*tan(d*x) - 4*tan(c))*b/(d*tan(d*x)*tan(c) - d)

Mupad [B] (verification not implemented)

Time = 11.39 (sec) , antiderivative size = 21, normalized size of antiderivative = 1.11 \[ \int \left (a+b \tan ^2(c+d x)\right ) \, dx=\frac {b\,\mathrm {tan}\left (c+d\,x\right )+d\,x\,\left (a-b\right )}{d} \]

[In]

int(a + b*tan(c + d*x)^2,x)

[Out]

(b*tan(c + d*x) + d*x*(a - b))/d